<?php

namespace Cmd\user;

use EasyWeChat\Kernel\Messages\News;
use EasyWeChat\Kernel\Messages\NewsItem;

class taobao
{
    public function taobao($message)
    {
        $img = [
            'https://img.alicdn.com/imgextra/i3/2053469401/O1CN01NmKoQd2JJi0Le61o3_!!2053469401.jpg',
            'https://img.alicdn.com/imgextra/i1/2053469401/O1CN013eJXfa2JJi0KtjBeE_!!2053469401.jpg',
            'https://img.alicdn.com/imgextra/i1/2053469401/O1CN01kD3b6d2JJi0Kat6Sy_!!2053469401.jpg',
            'https://img.alicdn.com/imgextra/i1/2053469401/O1CN01yNMU1s2JJi0Mf2ssS_!!2053469401.jpg',
            'https://img.alicdn.com/imgextra/i2/2053469401/O1CN01yeAbEZ2JJi0MTkwRT_!!2053469401.jpg',
        ];

        // 无搜索词则进首页
        if ($message == '' || $message == 'taobao' || $message == 'tb') {
            return new News([
                new NewsItem([
                    'title'       => '每天千款优惠券秒杀',
                    'description' => '淘特卖-优惠券折扣直播第一站！每天更新千款，纯人工筛选验货，限时限量特卖，全场1折包邮！~',
                    'url'         => 'http://www.ithou.cn?r=index/wap',
                    'image'       => $img[mt_rand(0, (count($img) - 1))],
                ])
            ]);
        }

        // 有搜索词则进搜索页
        return new News([
            new NewsItem([
                'title'       => '为您找到【' . $message . '】超值优惠券~',
                'description' => '淘特卖-优惠券折扣直播第一站！每天更新千款，纯人工筛选验货，限时限量特卖，全场1折包邮！~',
                'url'         => 'http://www.ithou.cn/index.php?input=1&screen=%5B%5D&activity=%5B%5D&brand=%5B%5D&r=index%2Fclassify&px=renqi&row=1&kw=' . urlencode($message) . '&activity_type=0&button_bnt=',
                'image'       => $img[mt_rand(0, (count($img) - 1))],
            ])
        ]);
    }
}
